﻿using Newtonsoft.Json.Linq;
using SQ.BLL.Factory;
using SQ.BLL.Implementation;
using SQ.BLL.Interfaces;
using SQ.Security.Criptografia;
using System;
using System.Collections.Generic;
using System.Linq;
using System.Net;
using System.Net.Http;
using System.Web.Http;

namespace SQ.API.Controllers
{
    [RoutePrefix("api/login")]
    public class LoginController : ApiController
    {
        ILoginBS loginBS = BLLFactory.getLoginBS();

        [Route("{email}")]
        [HttpPost]
        public HttpResponseMessage Logar(string email, [FromBody] string senha)
        {
            try
            {
                return Request.CreateResponse(HttpStatusCode.OK, loginBS.Logar(email, senha));
            }
            catch (ArgumentException ex)
            {
                return Request.CreateResponse(HttpStatusCode.BadRequest, ex.Message);
            }
            catch (Exception ex)
            {
                return Request.CreateResponse(HttpStatusCode.InternalServerError, ex.Message);
            }

        }

    }
}